package easy.id_0_100;


import easy.pojo.TreeNode;

public class Lee100 {
    public static void main(String[] args) {

    }

    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null && q!=null) return false;
        if(p!=null && q==null) return false;
        if(p==null && q==null) return true;
        return isSame(p,q) && isSame(p.left,q.left) && isSame(q.right,q.right);
    }
    public boolean isSame(TreeNode a,TreeNode b){
        if(a==null && b==null ){
            return true;
        }else if(a!=null && b!=null){
            return a.val==b.val && isSame(a.left,b.left) && isSame(a.right,b.right);
        }else{
            return false;
        }

    }
}
